class Solution {
private:
    vector<vector<int>> ans, graph;
    vector<int>path = {0};
    void dfs(int node, int n){
        if(node == n){
            ans.push_back(path);
            return;
        }
        for(int i = 0; i < graph[node].size(); i++){
            path.push_back(graph[node][i]);
            dfs(graph[node][i], n);
            path.pop_back();
        }
    }
    public:
    vector<vector<int>> allPathsSourceTarget(vector<vector<int>>& graph) {
        this->graph = graph;
        dfs(0, graph.size() - 1);
        return this->ans;
    }
};

/**
 * 2021.8.26
 * 回溯法 dfs 
 */